<?php

$name = trim($_POST['name']);
$qq = trim($_POST['qq']);
$text = trim($_POST['text']);
$time = gmdate("Y-m-d H:i:s",time()+8*3600);
$ip = trim($_POST['ip']);

include_once 'connect.php';
$charu = "insert into leaving (name,QQ,text,time,ip) values ('$name','$qq','$text','$time','$ip')";
$result = mysqli_query($connect,$charu);
if ($result) {
    echo "<script>alert('留言提交成功');location.href = '/leaving.php';</script>";
} else {
    echo "'<script>alert('留言失败');history.back();</script>";
}